version=17.0.6+2
_cert_ver=20210916

OLD_PATH=$PATH
export JAVA_HOME=$SRC/openjdk17-boot
export PATH=$JAVA_HOME/bin:$OLD_PATH

unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
unset MAKEFLAGS
export _CFLAGS+=' -fcommon'
export _CXXFLAGS+=' -fcommon'

[ -z $JOBS ] && JOBS=$(nproc)

mkdir $SRC/build
cd $SRC/build

LC_ALL=C
/bin/bash ../jdk17u-jdk-${version/+/-}/configure \
--enable-ccache \
--prefix=/usr/lib/jvm/java-17-openjdk \
--disable-precompiled-headers \
--disable-warnings-as-errors \
--enable-dtrace=no \
--enable-unlimited-crypto \
--with-native-debug-symbols=internal \
--with-debug-level=release \
--with-stdc++lib=dynamic \
--with-jvm-variants=server \
--with-cacerts-file=$KAYNAK_DIZIN/java_cacerts-${_cert_ver} \
--with-jtreg=no \
--with-boot-jdk=$JAVA_HOME \
--with-version-opt="Milis-r$devir" \
--with-version-build="${version#*+}" \
--with-vendor-name="Milis" \
--with-jobs=$MAKEJOBS \
--with-libjpeg=system \
--with-giflib=system \
--with-libpng=system \
--with-zlib=system \
--with-lcms=system \
--with-extra-cflags="$_CFLAGS" \
--with-extra-cxxflags="$_CXXFLAGS"

# NOTE: for debugging build issues: set LOG to debug, JOBS to 1.
LC_ALL=C \
make LOG=warn JOBS=$JOBS jdk-image
